<?php

function rpc( $json_request ) {
    global $PARAPARA;

    $req_param = $json_request->param;

    if(!$req_param) {
        return new RPC_Error($json_request->operation, "PARAM", "No params");
    }

    $thread_id = $req_param->thread_id;
    if(!is_numeric( $thread_id ) )
        return new RPC_Error($json_request->operation, "PARAM", "No thread_id");

    $thread = $PARAPARA->get_thread( $thread_id );
    if(!$thread )
        return new RPC_Error($json_request->operation, "NOT_FOUND", "No thread_id");


    $rpc_retval = 
        array( 
            'html'      => $thread->as_html( array( 'expanded' => true ) ),
            'thread_id' => $thread->id
            );

    return new RPC_Response( $json_request->operation, $rpc_retval );


}

return rpc( $json_request );


?>